using System;
using System.Collections.Generic;
using System.Text;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Content;

namespace OrtzEng.Graphics
{
    public class SpriteManager
    {
        private SpriteBatch _spriteBatch;
        private List<Sprite> _spriteList;
        private ContentManager _contentManager;

        public SpriteManager(Game game, GraphicsDeviceManager graphics)
        {
            _spriteBatch = new SpriteBatch(graphics.GraphicsDevice);
            _spriteList = new List<Sprite>();
            _contentManager = new ContentManager(game.Services);
        }

        public void Draw()
        {
            _spriteBatch.Begin();
            foreach (Sprite cur in _spriteList)
            {
                cur.Draw(_spriteBatch);
            }
            _spriteBatch.End();
        }
        public Sprite Add(string texturePath)
        {
            Sprite newSprite = new Sprite(texturePath);
            newSprite.Initialize();
            newSprite.LoadGraphicsContent(_contentManager);
            _spriteList.Add(newSprite);

            return newSprite;
        }
        public void Add(Sprite sprite)
        {
            sprite.Initialize();
            sprite.LoadGraphicsContent(_contentManager);
            _spriteList.Add(sprite);
        }
    }
}
